home *** CD-ROM | disk | FTP | other *** search
/ Turnbull China Bikeride / Turnbull China Bikeride - Disc 2.iso / STUTTGART / LANG / C / LIB / UNIXLIB37B / !UnixLib37 / src / c / strstr < prev    next >
Text File  |  1996-11-09  |  791b  |  35 lines

  1. /****************************************************************************
  2.  *
  3.  * $Source: /unixb/home/unixlib/source/unixlib37/src/c/RCS/strstr,v $
  4.  * $Date: 1996/04/19 21:26:42 $
  5.  * $Revision: 1.1 $
  6.  * $State: Rel $
  7.  * $Author: simon $
  8.  *
  9.  * $Log: strstr,v $
  10.  * Revision 1.1  1996/04/19 21:26:42  simon
  11.  * Initial revision
  12.  *
  13.  ***************************************************************************/
  14.  
  15. static const char rcs_id[] = "$Id: strstr,v 1.1 1996/04/19 21:26:42 simon Rel $";
  16.  
  17. #include <string.h>
  18.  
  19. char *
  20. strstr (register const char *s1, register const char *s2)
  21.  
  22. {
  23.   register int l1 = strlen (s1), l2 = strlen (s2);
  24.   register const char *e1 = s1 + l1 - l2;
  25.  
  26.   while (s1 <= e1)
  27.     {
  28.       if (!strncmp (s1, s2, l2))
  29.     return ((char *) s1);
  30.       s1++;
  31.     }
  32.  
  33.   return (0);
  34. }
  35.